

/**
 * DataTables
 */
var datatable = null,idList=[];

$(function() {
	datatable = $('.table-sort').dataTable({
		order: [
			[1, 'asc']
		],
		bRetrieve: true,
		autoWidth: true,
		searching : false,
		lengthChange: false,	
		processing: true, //当datatable获取数据时候是否显示正在处理提示信息。
		serverSide: true, //服务器处理分页
		responsive: {
			details: false
		},
	    //lengthMenu: [10],   // 每页显示数据（默认是10）
	    ordering: false,//是否允许用户排序
	    paging: true,//是否分页
	    pagingType: "full_numbers",//除首页、上一页、下一页、末页四个按钮还有页数按钮
	    /* scrollX: true,//允许水平滚动
	     scrollY: "200px",
	     scrollCollapse: true, */
	    stateSave: false,//刷新时是否保存状态
	    //deferRender: true,//延迟渲染
		ajax: {
			url: contextPath + "/report/getPageList1",
			type: 'post',
			data: function(d) {
				//d.search = $('#search').val();
			}
		},	
		language: {
			"url": "../resources/js/datatables_language.json"
		},
		columns: [
			{data: "inventoryId"},
			{data: "cardNumber",defaultContent: ""},
			{data: "state",defaultContent: ""}
			],
		columnDefs: [{
			targets: [0],
			orderable:false,
			render: function(data, type, row, meta) {
				return '<input id="input-' + data + '" type="checkbox" name="single"><label for="input-' + data + '"></label>';
			}
		},{
			targets: [2],
			render: function(data, type, row, meta) {
				var str;
				switch(data){
				case 1:
					str = '绑定';
					break;
				case 0:
					str = '购买';
					break;
				case 2:
					str = '赠送';
					break;
				}
				return str;
			}
		}]
	});

});

